﻿namespace HRM.CORE
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;

    public class xfmSalaryPayOption : XtraForm
    {
        private SimpleButton btCancel;
        private SimpleButton btCreate;
        private CalcEdit calMoney;
        private CalcEdit calPercent;
        private ComboBoxEdit cboOrder;
        private CheckEdit cheIsSkip;
        private IContainer components = null;
        private DateEdit dtDate;
        private GroupBox groupBox1;
        private DevExpress.Utils.ImageCollection imageCollection1;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private LabelControl labelControl3;
        private LabelControl labelControl4;
        private LabelControl labelControl5;
        private LabelControl labelControl6;
        private LabelControl lcDescription;
        private PanelControl panelControl1;
        private RadioGroup rdgOption;
        private TextEdit txtDescription;
        private TextEdit txtPerson;

        public event CreatedHander Created;

        public xfmSalaryPayOption()
        {
            this.InitializeComponent();
        }

        private void btCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btCreate_Click(object sender, EventArgs e)
        {
            if (this.rdgOption.SelectedIndex == 0)
            {
                this.RaiseCreatedHander(int.Parse(this.cboOrder.Text), this.dtDate.DateTime, this.rdgOption.SelectedIndex, double.Parse(this.calMoney.EditValue.ToString()), this.txtPerson.Text, this.txtDescription.Text, this.cheIsSkip.Checked);
            }
            else if (this.rdgOption.SelectedIndex == 1)
            {
                this.RaiseCreatedHander(int.Parse(this.cboOrder.Text), this.dtDate.DateTime, this.rdgOption.SelectedIndex, double.Parse(this.calPercent.EditValue.ToString()), this.txtPerson.Text, this.txtDescription.Text, this.cheIsSkip.Checked);
            }
            else
            {
                this.RaiseCreatedHander(int.Parse(this.cboOrder.Text), this.dtDate.DateTime, this.rdgOption.SelectedIndex, 0.0, this.txtPerson.Text, this.txtDescription.Text, this.cheIsSkip.Checked);
            }
            base.Close();
        }

        private void cboOrder_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.cboOrder.SelectedIndex == 0)
            {
                this.rdgOption.Properties.Items[2].Enabled = true;
            }
            else
            {
                this.rdgOption.Properties.Items[2].Enabled = false;
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xfmSalaryPayOption));
            this.btCreate = new SimpleButton();
            this.imageCollection1 = new DevExpress.Utils.ImageCollection(this.components);
            this.btCancel = new SimpleButton();
            this.lcDescription = new LabelControl();
            this.panelControl1 = new PanelControl();
            this.cheIsSkip = new CheckEdit();
            this.cboOrder = new ComboBoxEdit();
            this.labelControl1 = new LabelControl();
            this.rdgOption = new RadioGroup();
            this.groupBox1 = new GroupBox();
            this.labelControl3 = new LabelControl();
            this.calMoney = new CalcEdit();
            this.labelControl2 = new LabelControl();
            this.calPercent = new CalcEdit();
            this.labelControl4 = new LabelControl();
            this.dtDate = new DateEdit();
            this.labelControl5 = new LabelControl();
            this.labelControl6 = new LabelControl();
            this.txtPerson = new TextEdit();
            this.txtDescription = new TextEdit();
            this.imageCollection1.BeginInit();
            this.panelControl1.BeginInit();
            this.panelControl1.SuspendLayout();
            this.cheIsSkip.Properties.BeginInit();
            this.cboOrder.Properties.BeginInit();
            this.rdgOption.Properties.BeginInit();
            this.groupBox1.SuspendLayout();
            this.calMoney.Properties.BeginInit();
            this.calPercent.Properties.BeginInit();
            this.dtDate.Properties.VistaTimeProperties.BeginInit();
            this.dtDate.Properties.BeginInit();
            this.txtPerson.Properties.BeginInit();
            this.txtDescription.Properties.BeginInit();
            base.SuspendLayout();
            this.btCreate.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btCreate.ImageIndex = 2;
            this.btCreate.ImageList = this.imageCollection1;
            this.btCreate.Location = new Point(0xb8, 10);
            this.btCreate.Name = "btCreate";
            this.btCreate.Size = new Size(0x6a, 0x17);
            this.btCreate.TabIndex = 2;
            this.btCreate.Text = "Đồng \x00dd (>>)";
            this.btCreate.Click += new EventHandler(this.btCreate_Click);
            this.imageCollection1.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection1.ImageStream");
            this.imageCollection1.Images.SetKeyName(0, "ico_alpha_Search_16x16.png");
            this.imageCollection1.Images.SetKeyName(1, "ico_alpha_Delete_16x16.png");
            this.imageCollection1.Images.SetKeyName(2, "document2.png");
            this.imageCollection1.Images.SetKeyName(3, "open-16x16.png");
            this.imageCollection1.Images.SetKeyName(4, "close.png");
            this.btCancel.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            this.btCancel.ImageIndex = 4;
            this.btCancel.ImageList = this.imageCollection1;
            this.btCancel.Location = new Point(0x132, 10);
            this.btCancel.Name = "btCancel";
            this.btCancel.Size = new Size(0x62, 0x17);
            this.btCancel.TabIndex = 3;
            this.btCancel.Text = "Tho\x00e1t";
            this.btCancel.Click += new EventHandler(this.btCancel_Click);
            this.lcDescription.Appearance.Options.UseTextOptions = true;
            this.lcDescription.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.lcDescription.AutoSizeMode = LabelAutoSizeMode.None;
            this.lcDescription.Location = new Point(0x11, 5);
            this.lcDescription.Name = "lcDescription";
            this.lcDescription.Size = new Size(0x185, 0x33);
            this.lcDescription.TabIndex = 4;
            this.lcDescription.Text = "    Chọn lần thanh to\x00e1n từ \x00f4 ph\x00eda b\x00ean dưới, sau đ\x00f3 nhập số tiền thanh to\x00e1n bằng tiền hoặc theo tỷ lệ % so với tiền lương thực l\x00e3nh để ph\x00e1t sinh dữ liệu.";
            this.panelControl1.Appearance.BackColor = Color.Transparent;
            this.panelControl1.Appearance.Options.UseBackColor = true;
            this.panelControl1.BorderStyle = BorderStyles.NoBorder;
            this.panelControl1.Controls.Add(this.cheIsSkip);
            this.panelControl1.Controls.Add(this.btCancel);
            this.panelControl1.Controls.Add(this.btCreate);
            this.panelControl1.Dock = DockStyle.Bottom;
            this.panelControl1.Location = new Point(0, 0x132);
            this.panelControl1.Name = "panelControl1";
            this.panelControl1.Size = new Size(0x1a5, 0x2b);
            this.panelControl1.TabIndex = 6;
            this.cheIsSkip.EditValue = true;
            this.cheIsSkip.Location = new Point(0x11, 12);
            this.cheIsSkip.Name = "cheIsSkip";
            this.cheIsSkip.Properties.Caption = "Bỏ qua nếu tồn tại";
            this.cheIsSkip.Size = new Size(0x79, 0x13);
            this.cheIsSkip.TabIndex = 4;
            this.cboOrder.EditValue = "1";
            this.cboOrder.Location = new Point(0x77, 0x3b);
            this.cboOrder.Name = "cboOrder";
            this.cboOrder.Properties.Appearance.Font = new Font("Tahoma", 8.25f, FontStyle.Bold);
            this.cboOrder.Properties.Appearance.Options.UseFont = true;
            this.cboOrder.Properties.Appearance.Options.UseTextOptions = true;
            this.cboOrder.Properties.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
            this.cboOrder.Properties.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.cboOrder.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cboOrder.Properties.Items.AddRange(new object[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" });
            this.cboOrder.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
            this.cboOrder.Size = new Size(0x47, 20);
            this.cboOrder.TabIndex = 7;
            this.cboOrder.SelectedIndexChanged += new EventHandler(this.cboOrder_SelectedIndexChanged);
            this.labelControl1.AllowHtmlString = true;
            this.labelControl1.Location = new Point(0x13, 0x3e);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x5e, 14);
            this.labelControl1.TabIndex = 8;
            this.labelControl1.Text = "Lần thanh to\x00e1n <color=blue>(*)</color>:";
            this.rdgOption.Location = new Point(15, 0x13);
            this.rdgOption.Name = "rdgOption";
            this.rdgOption.Properties.Appearance.BackColor = Color.Transparent;
            this.rdgOption.Properties.Appearance.Options.UseBackColor = true;
            this.rdgOption.Properties.BorderStyle = BorderStyles.NoBorder;
            this.rdgOption.Properties.Items.AddRange(new RadioGroupItem[] { new RadioGroupItem(null, "Thanh to\x00e1n theo số tiền mặc định"), new RadioGroupItem(null, "Thanh to\x00e1n theo tỷ lệ % tiền lương"), new RadioGroupItem(null, "Thanh to\x00e1n theo số tiền khai b\x00e1o trong th\x00f4ng tin nh\x00e2n vi\x00ean"), new RadioGroupItem(null, "Thanh to\x00e1n hết phần c\x00f2n lại") });
            this.rdgOption.Size = new Size(0x145, 0x81);
            this.rdgOption.TabIndex = 9;
            this.rdgOption.SelectedIndexChanged += new EventHandler(this.rdgOption_SelectedIndexChanged);
            this.groupBox1.Controls.Add(this.labelControl3);
            this.groupBox1.Controls.Add(this.calMoney);
            this.groupBox1.Controls.Add(this.labelControl2);
            this.groupBox1.Controls.Add(this.calPercent);
            this.groupBox1.Controls.Add(this.rdgOption);
            this.groupBox1.Location = new Point(0x11, 0x5f);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(0x183, 0x94);
            this.groupBox1.TabIndex = 10;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Số tiền thanh to\x00e1n trong đợt";
            this.labelControl3.AllowHtmlString = true;
            this.labelControl3.Location = new Point(0x155, 0x20);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x1d, 14);
            this.labelControl3.TabIndex = 13;
            this.labelControl3.Text = "<color=blue>(VNĐ)</color>";
            int[] bits = new int[4];
            bits[0] = 0xf4240;
            this.calMoney.EditValue = new decimal(bits);
            this.calMoney.Location = new Point(230, 0x1d);
            this.calMoney.Name = "calMoney";
            this.calMoney.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calMoney.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.calMoney.Size = new Size(0x6a, 20);
            this.calMoney.TabIndex = 12;
            this.labelControl2.AllowHtmlString = true;
            this.labelControl2.Location = new Point(0x15a, 0x3e);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(0x13, 14);
            this.labelControl2.TabIndex = 11;
            this.labelControl2.Text = "<color=blue>(%)</color>";
            bits = new int[4];
            bits[0] = 100;
            this.calPercent.EditValue = new decimal(bits);
            this.calPercent.Enabled = false;
            this.calPercent.Location = new Point(230, 0x3b);
            this.calPercent.Name = "calPercent";
            this.calPercent.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.calPercent.Size = new Size(0x6a, 20);
            this.calPercent.TabIndex = 10;
            this.labelControl4.AllowHtmlString = true;
            this.labelControl4.Location = new Point(0xc7, 0x3e);
            this.labelControl4.Name = "labelControl4";
            this.labelControl4.Size = new Size(0x66, 14);
            this.labelControl4.TabIndex = 8;
            this.labelControl4.Text = "Ng\x00e0y thanh to\x00e1n <color=blue>(*)</color>:";
            this.dtDate.EditValue = null;
            this.dtDate.Location = new Point(0x130, 60);
            this.dtDate.Name = "dtDate";
            this.dtDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtDate.Size = new Size(100, 20);
            this.dtDate.TabIndex = 11;
            this.labelControl5.AllowHtmlString = true;
            this.labelControl5.Location = new Point(0x11, 0xfd);
            this.labelControl5.Name = "labelControl5";
            this.labelControl5.Size = new Size(0x3f, 14);
            this.labelControl5.TabIndex = 8;
            this.labelControl5.Text = "Người duyệt:";
            this.labelControl6.AllowHtmlString = true;
            this.labelControl6.Location = new Point(0x11, 280);
            this.labelControl6.Name = "labelControl6";
            this.labelControl6.Size = new Size(0x27, 14);
            this.labelControl6.TabIndex = 8;
            this.labelControl6.Text = "Ghi ch\x00fa:";
            this.txtPerson.Location = new Point(0x56, 250);
            this.txtPerson.Name = "txtPerson";
            this.txtPerson.Size = new Size(0x13e, 20);
            this.txtPerson.TabIndex = 0x11;
            this.txtDescription.Location = new Point(0x56, 0x115);
            this.txtDescription.Name = "txtDescription";
            this.txtDescription.Size = new Size(0x13e, 20);
            this.txtDescription.TabIndex = 0x11;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x1a5, 0x15d);
            base.Controls.Add(this.txtDescription);
            base.Controls.Add(this.txtPerson);
            base.Controls.Add(this.dtDate);
            base.Controls.Add(this.groupBox1);
            base.Controls.Add(this.labelControl4);
            base.Controls.Add(this.labelControl6);
            base.Controls.Add(this.labelControl5);
            base.Controls.Add(this.labelControl1);
            base.Controls.Add(this.cboOrder);
            base.Controls.Add(this.panelControl1);
            base.Controls.Add(this.lcDescription);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "xfmSalaryPayOption";
            base.ShowIcon = false;
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "T\x00f9y Chọn Ph\x00e1t Sinh Thanh To\x00e1n Lương";
            base.Load += new EventHandler(this.xfmSalaryPayOption_Load);
            this.imageCollection1.EndInit();
            this.panelControl1.EndInit();
            this.panelControl1.ResumeLayout(false);
            this.cheIsSkip.Properties.EndInit();
            this.cboOrder.Properties.EndInit();
            this.rdgOption.Properties.EndInit();
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.calMoney.Properties.EndInit();
            this.calPercent.Properties.EndInit();
            this.dtDate.Properties.VistaTimeProperties.EndInit();
            this.dtDate.Properties.EndInit();
            this.txtPerson.Properties.EndInit();
            this.txtDescription.Properties.EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void RaiseCreatedHander(int Order, DateTime Date, int PayType, double Value, string Person, string Description, bool IsSkip)
        {
            if (this.Created != null)
            {
                this.Created(this, Order, Date, PayType, Value, Person, Description, IsSkip);
            }
        }

        private void rdgOption_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.rdgOption.SelectedIndex == 0)
            {
                this.calMoney.Enabled = true;
                this.calPercent.Enabled = false;
            }
            else if (this.rdgOption.SelectedIndex == 1)
            {
                this.calMoney.Enabled = false;
                this.calPercent.Enabled = true;
            }
            else
            {
                this.calMoney.Enabled = false;
                this.calPercent.Enabled = false;
            }
        }

        private void xfmSalaryPayOption_Load(object sender, EventArgs e)
        {
            this.dtDate.DateTime = DateTime.Now;
        }

        public delegate void CreatedHander(object sender, int Order, DateTime Date, int PayType, double Value, string Person, string Description, bool IsSkip);
    }
}

